#include <stdio.h>
#include <unistd.h>
#include <sys/wait.h>
#include <stdlib.h>

int main()
{
    printf("我的程序要运行了!\n");

    if (fork() == 0)
    {
        printf("I am child, My PID is: %d\n", getpid());

        char* const argv[] = {
            (char* const)"ls",
            (char* const)"-l",
            (char* const)"-a",
            NULL 
        };
        
        // int execv(const char *path, char *const argv[]);
        execv("/usr/bin/ls", argv);

        exit(1);
    }

    waitpid(-1, NULL, 0);
    printf("我的程序运行完毕了\n");
    return 0;
}
